package com.dfk.bs.service.user.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dfk.bs.dao.user.BaoxiuMapper;
import com.dfk.bs.entity.vo.Baoxiu;
import com.dfk.bs.service.user.BaoxiuService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class BaoxiuServiceImpl extends ServiceImpl<BaoxiuMapper, Baoxiu> implements BaoxiuService {


    @Override
    public void pageQuery(Page<Baoxiu> pageParam, String selectname) {
        QueryWrapper<Baoxiu> queryWrapper = new QueryWrapper<>();
        /*查询出来排序 根据表中的sort字段排序*/
        queryWrapper.orderByDesc("createtime");
        //queryWrapper.orderByAsc("createtime");
        if (selectname == null) {
            baseMapper.selectPage(pageParam, queryWrapper);
            return;
        }
        /*两个条件  根据用电器id或者状态搜索分页*/
        if (!StringUtils.isEmpty(selectname)) {
            queryWrapper.like("name", selectname);
        }
        if (!StringUtils.isEmpty(selectname)) {
            queryWrapper.or().like("eleappname", selectname);
        }
        baseMapper.selectPage(pageParam, queryWrapper);

    }
}
